#ifndef SOCK_SERVER_FRAME_H_934UIO7E49ULSKDVJLD
#define SOCK_SERVER_FRAME_H_934UIO7E49ULSKDVJLD

#include "List.h"
#include "Socket.h"

#ifdef __cplusplus
extern "C" {
#endif


typedef struct sock_client_session
{
	/* public */
	SOCKET fd;
	BOOL need_close;
	void* ptr;

	/* private */
	ListPosition pos;
}sock_client_session;

typedef struct sock_server_info
{
	/* public */
	SOCKET fd;
	BOOL (*onAccept)(sock_client_session* sess);
	void (*onClose)(sock_client_session* sess);
	void (*onRecv)(sock_client_session* sess);
	void (*onSend)(sock_client_session* sess);
	struct timeval timeout;
	BOOL isrun;

    /* private */
	int sockCount;
	List* sockList;
	int maxfd;
	fd_set rset;
	fd_set wset;
}sock_server_info;

sock_server_info* sock_server_init(SOCKET fd);
void sock_server_free(sock_server_info* info);

int sock_server_run(sock_server_info* trans);







#ifdef __cplusplus
}
#endif
#endif /* SOCK_SERVER_FRAME_H_934UIO7E49ULSKDVJLD */
